var arr = [3, 5, 7, 1, 4, 56, 12, 78, 25, 0, 9, 8, 42, 37]

var sortArray = function (arr) {
  if (arr.length < 2) return arr
  const len = arr.length
  const left = [],
    right = []
  const mid = arr[0]
  for (let i = 1; i < len; i++) {
    if (arr[i] < mid) {
      left.push(arr[i])
    } else {
      right.push(arr[i])
    }
  }
  return sortArray(left).concat(mid, sortArray(right))
}

console.log(sortArray(arr))

function swap(arr, i, j) {
  let temp = arr[i]
  arr[i] = arr[j]
  arr[j] = temp
}
